<?php
if(!defined('BZ_XTBLOG')){
    exit('Access Denied!');
}
function forum_class($lexi='1',$num='5',$typeb='0',$type='0'){
	  	global $db,$Bingz_ml,$Bingz_md,$Bingz_html,$user_class,$wappced;
   if($typeb== '0'){
	    $where1=' `sz_sc` = \'0\' ';
	 }else{
      $where1=' `sz_sc` = \'0\' AND `cid` ='.$typeb.'';
   }
	 if($lexi != '1'){$where1=$where1.' AND `type` = \'3\'';}
   if($type==1){
      $sql=$db->query('forum',"$where1 ORDER BY RAND() DESC LIMIT 0 , $num",'');
   }elseif($type==2){
      $sql=$db->query('forum',"$where1 ORDER BY `cks` DESC LIMIT 0 , $num",'');
   }elseif($type==3){
      $sql=$db->query('forum',"$where1 ORDER BY `hfs` DESC LIMIT 0 , $num",'');
   }elseif($type==4){
      $sql=$db->query('forum',"$where1 ORDER BY `time_a` DESC LIMIT 0 , $num",'');
   }elseif($type==5){
      $sql=$db->query('forum',"$where1 AND `type_jin` = '1' ORDER BY `time_a` DESC LIMIT 0 , $num",'');
   }elseif($type==6){
      $sql=$db->query('forum',"$where1 AND `cun` = '1' ORDER BY `time_a` DESC LIMIT 0 , $num",'');
   }else{
   	  $sql=$db->query('forum',"$where1 ORDER BY `id` DESC LIMIT 0 , $num",'');
   }
   $hy='';
   $ab='';
if($wappced == 'wap'){
   while($dmt=mysql_fetch_array($sql)){
   	     $sjts=date('m/d',$dmt['time_b']);
	       $dmt['name'] =Bingz_html($dmt['name']);
	    	 $dmtname =mb_substr($dmt['name'],0,14,"utf-8");
        if(!$Bingz_html){
        	  $httlmp='index.php?'.$Bingz_ml.'=forum&amp;'.$Bingz_md.'=viewthread&amp;fid='.$dmt[id].'';
        }else{
        		$httlmp='forum-viewthread-'.$dmt[id].'.html';
        }
         $hy=$hy.''.$typedd.'<a href="'.$httlmp.'"><b>['.$sjts.']</b>'.$dmtname.'</a><br/>';
	 }
	 return $hy;
}else{
if($lexi == '2'){
   while($dmt=mysql_fetch_array($sql)){
	       $dmt['name'] =Bingz_html($dmt['name']);
	    	 $dmtname =mb_substr($dmt['name'],0,15,"utf-8");
	    	 $wzfj=$db->get_one('forum_data'," `fid` = '$dmt[id]' AND `fjgs` = '1' AND `money` = '0' ORDER BY `paixi`",'');
	    	 if(!$wzfj){
	    	 	   $wzfj[url]='images/forum/suos.jpg';
	    	 }
        if(!$Bingz_html){
        	  $httlmp='index.php?'.$Bingz_ml.'=forum&amp;'.$Bingz_md.'=viewthread&amp;fid='.$dmt[id].'';
        }else{
        		$httlmp='forum-viewthread-'.$dmt[id].'.html';
        }
        $hy=$hy.'<li>'.$typedd.'<a class="pic" href="'.$httlmp.'"><img src="data/forum/'.$wzfj[url].'" alt="'.$dmtname.'"/></a><a class="tit" href="'.$httlmp.'">'.$dmtname.'</a></li>';
	 }
return '
<div id="slideBox" class="slideBox">
<div class="bd">
<ul>
'.$hy.'
</ul>
</div>
<div class="hd">
<ul></ul>
</div>
</div>
<script type="text/javascript">
TouchSlide({ 
slideCell:"#slideBox",
titCell:".hd ul",
mainCell:".bd ul", 
effect:"leftLoop", 
autoPage:true,
autoPlay:true
});
</script>
';
}elseif($lexi == '3'){
   while($dmt=mysql_fetch_array($sql)){
	       $dmt['name'] =Bingz_html($dmt['name']);
	    	 $dmtname =mb_substr($dmt['name'],0,10,"utf-8");
	    	 $dmtcontent =mb_substr($dmt['content'],0,300,"utf-8");
	    	 
         if(preg_match("/\[attach\]([0-9]{1,9})\[\/attach\]/",$dmtcontent,$sms)){
            $dmtcontent=str_replace("[attach]".$sms[1]."[/attach]",'',$dmtcontent);
         }  

 	    	 $dmtcontent =mb_substr($dmtcontent,0,20,"utf-8");
	    	 if(!$dmtcontent){$dmtcontent =mb_substr($dmt['content'],0,20,"utf-8");}
	    	 $lz_name    =$user_class->user_name($dmt[uid]);
	    	 $wzfj=$db->get_one('forum_data'," `fid` = '$dmt[id]' AND `fjgs` = '1' AND `money` = '0' ORDER BY `paixi`",'');
	    	 if(!$wzfj){
	    	 	   $wzfj[url]='images/forum/suos.jpg';
	    	 }
        if(!$Bingz_html){
        	  $httlmp='index.php?'.$Bingz_ml.'=forum&amp;'.$Bingz_md.'=viewthread&amp;fid='.$dmt[id].'';
        }else{
        		$httlmp='forum-viewthread-'.$dmt[id].'.html';
        }
        $hy=$hy.'<li>'.$typedd.'<a href="'.$httlmp.'" class="c"><img src="data/forum/'.$wzfj[url].'" width="62" height="62" /><h3>'.$dmtname.'</h3><p>用户：'.$lz_name.'   ('.$dmt[hfs].'/'.$dmt[cks].') </p><p>'.$dmtcontent.'</p></a></li>';
	 }
	return '<div class="listViewIcon5"><ul>'.$hy.'</ul></div>';
}else{
   while($dmt=mysql_fetch_array($sql)){
   	     $sjts=date('m/d',$dmt['time_b']);
	       $dmt['name'] =Bingz_html($dmt['name']);
	    	 $dmtname =mb_substr($dmt['name'],0,14,"utf-8");
        if(!$Bingz_html){
        	  $httlmp='index.php?'.$Bingz_ml.'=forum&amp;'.$Bingz_md.'=viewthread&amp;fid='.$dmt[id].'';
        }else{
        		$httlmp='forum-viewthread-'.$dmt[id].'.html';
        }
         $hy=$hy.'<li>'.$typedd.'<a href="'.$httlmp.'"><p><b>['.$sjts.']</b> <font color="#000099">'.$dmtname.'</font></p><i class="iconArrowR">右箭头</i></a></li>';
	 }
	return '<div class="listViewDis1"><ul>'.$hy.'</ul></div>';
}
}
}
function user_class($num='5',$type='1'){
	  	global $db,$_config,$Bingz_ml,$Bingz_md,$user_class,$Bingz_html,$wappced;
   if($type==1){
      $sql=$db->query('user'," ORDER BY RAND() DESC LIMIT 0 , $num",'');
   }elseif($type==2){
      $sql=$db->query('user'," ORDER BY RAND() DESC LIMIT 0 , $num",'');
   }elseif($type==3){
      $sql=$db->query('user',"`show` = 0  ORDER BY `uid` DESC LIMIT 0 , $num",'');
   }elseif($type==4){
      $sql=$db->query('user'," ORDER BY `time_a` DESC LIMIT 0 , $num",'');
   }elseif($type==5){
      $sql=$db->query('user'," `user_zx` = 5 ORDER BY `uid` DESC LIMIT 0 , $num",'');
   }else{
   	  $sql=$db->query('user'," ORDER BY `uid` DESC LIMIT 0 , $num",'');
   }
   $hy='';
if($wappced == 'wap'){
   while($dmt=mysql_fetch_array($sql)){
        $lz_name      =$user_class->user_name($dmt[uid]);
        $lz_zhuangtai      =$user_class->user_zhuangtai($dmt[uid]);
        $lz_sex       =$user_class->user_sex($dmt[uid],'1');
        $lz_tx        =$user_class->user_tx($dmt[uid]);
        $lz_qm        =$user_class->user_qm($dmt[uid]);
        $lz_qm =mb_substr($lz_qm,0,10,"utf-8");
        if(!$Bingz_html){
        	  $httlmp='index.php?'.$Bingz_ml.'=user&amp;uid='.$dmt[uid].'';
        }else{
        		$httlmp='user-'.$dmt[uid].'.html';
        }
        $hy=$hy.'<li>'.$typedd.'<a href="'.$httlmp.'" class="c"><img src="'.$lz_tx.'" width="62" height="62" /><h3>'.$lz_name.'</h3><p>性别：'.$lz_sex.'   ('.$lz_zhuangtai.') </p><p>签名：'.$lz_qm.'<i class="fa fa-apple icon"></i></p><i class="iconArrowR">右箭头</i></a></li>';
	 }
	return '<div class="listViewIcon1"><ul>'.$hy.'</ul></div>';
 }else{
   while($dmt=mysql_fetch_array($sql)){
        $lz_name      =$user_class->user_name($dmt[uid]);
        $lz_zhuangtai      =$user_class->user_zhuangtai($dmt[uid]);
        $lz_sex       =$user_class->user_sex($dmt[uid],'1');
        $lz_tx        =$user_class->user_tx($dmt[uid]);
        $lz_qm        =$user_class->user_qm($dmt[uid]);
        $lz_qm =mb_substr($lz_qm,0,10,"utf-8");
        if(!$Bingz_html){
        	  $httlmp='index.php?'.$Bingz_ml.'=user&amp;uid='.$dmt[uid].'';
        }else{
        		$httlmp='user-'.$dmt[uid].'.html';
        }
        $hy=$hy.'<li>'.$typedd.'<a href="'.$httlmp.'" class="c"><img src="'.$lz_tx.'" width="62" height="62" /><h3>'.$lz_name.'</h3><p>性别：'.$lz_sex.'   ('.$lz_zhuangtai.') </p><p>签名：'.$lz_qm.'<i class="fa fa-apple icon"></i></p><i class="iconArrowR">右箭头</i></a></li>';
	 }
	return '<div class="listViewIcon1"><ul>'.$hy.'</ul></div>';
	}
}
function link_class($num='',$type='',$typea=''){
	  	global $db,$Bingz_ml,$Bingz_md,$wappced;
	 if($type==0){
	    $where1='`check`= 0';
	 }else if($type==1){
      $where1='`type`=1 AND `check`=0 ';
   }else if($type==2){
      $where1='`type`=2 AND `check`=0 ';
   }else if($type==3){
      $where1='`type`=3 AND `check`=0 ';
   }else if($type==4){
      $where1='`type`=4 AND `check`=0 ';
   }
   if($typea==0){
      $sql=$db->query('link'," $where1 ORDER BY `id` DESC LIMIT 0 , $num",'');
   }else if($typea==1){
      $sql=$db->query('link'," $where1 ORDER BY `id` LIMIT 0 , $num",'');
   }else if($typea==2){
      $sql=$db->query('link'," $where1 ORDER BY `click` DESC LIMIT 0 , $num",'');
   }else if($typea==3){
      $sql=$db->query('link'," $where1 ORDER BY RAND() DESC LIMIT 0 , $num",'');
   }
		$hh=1;
		$type_txt='';
if($wappced == 'wap'){
	   while($dmt=mysql_fetch_array($sql)){
			$name =Bingz_html($dmt['namem']);
      $name=mb_substr($name,0,2,"utf-8");
      $rttm=' = ';
      if($hh == '5'){$rttm='<br/>';}elseif($hh == '10'){$rttm='<br/>';}elseif($hh == '15'){$rttm='<br/>';}elseif($hh == '20'){$rttm='<br/>';}
      $type_txt=$type_txt."<a href=\"index.php?".$Bingz_ml."=link&amp;".$Bingz_md."=go&amp;gid=$dmt[id]\">$name</a>".$rttm;
    $hh++;
	 }
	 return $type_txt;
 }else{
	   while($dmt=mysql_fetch_array($sql)){
			$name =Bingz_html($dmt['namem']);
      $name=mb_substr($name,0,2,"utf-8");
      $type_txt=$type_txt."<a href=\"index.php?".$Bingz_ml."=link&amp;".$Bingz_md."=go&amp;gid=$dmt[id]\">$name</a>";
    $hh++;
	 }
	 if($type_txt){
	 return "<div class=\"link\">".$type_txt."</div>";
	 }
	 }
}

function Bingz_banben(){
	  	global $wappced,$Bingz_ml,$Bingz_md;
	 if($wappced=='wap'){
	    $Bingz_banben='<a href="index.php?'.$Bingz_ml.'=user&amp;'.$Bingz_md.'=sid&amp;act=bvb&amp;banben=wap"><font color="#000000"><b>简版</b></font></a> | <a href="index.php?'.$Bingz_ml.'=user&amp;'.$Bingz_md.'=sid&amp;act=bvb&amp;banben=wpc"><font color="#5E5E5E">触屏</font></a> | <a href="index.php?'.$Bingz_ml.'=user&amp;'.$Bingz_md.'=sid&amp;act=bvb&amp;banben=web"><font color="#5E5E5E">电脑版</font></a>';
	 }else if($wappced=='wpc'){
	    $Bingz_banben='<a href="index.php?'.$Bingz_ml.'=user&amp;'.$Bingz_md.'=sid&amp;act=bvb&amp;banben=wap"><font color="#5E5E5E">简版</font></a> | <a href="index.php?'.$Bingz_ml.'=user&amp;'.$Bingz_md.'=sid&amp;act=bvb&amp;banben=wpc"><font color="#000000"><b>触屏</b></font></a> | <a href="index.php?'.$Bingz_ml.'=user&amp;'.$Bingz_md.'=sid&amp;act=bvb&amp;banben=web"><font color="#5E5E5E">电脑版</font></a>';
   }else if($wappced=='web'){
	    $Bingz_banben='<a href="index.php?'.$Bingz_ml.'=user&amp;'.$Bingz_md.'=sid&amp;act=bvb&amp;banben=wap"><font color="#5E5E5E">简版</font></a> | <a href="index.php?'.$Bingz_ml.'=user&amp;'.$Bingz_md.'=sid&amp;act=bvb&amp;banben=wpc"><font color="#5E5E5E">触屏</font></a> | <a href="index.php?'.$Bingz_ml.'=user&amp;'.$Bingz_md.'=sid&amp;act=bvb&amp;banben=web"><font color="#000000"><b>电脑版</b></font></a>';
   }
	 return $Bingz_banben;
}
############################
function attachtype($type, $returnval = 'html') {
	static $attachicons = array(
			1 => 'unknown.gif',
			2 => 'binary.gif',
			3 => 'zip.gif',
			4 => 'rar.gif',
			5 => 'msoffice.gif',
			6 => 'text.gif',
			7 => 'html.gif',
			8 => 'real.gif',
			9 => 'av.gif',
			10 => 'flash.gif',
			11 => 'image.gif',
			12 => 'pdf.gif',
			13 => 'torrent.gif'
		);

	if(is_numeric($type)) {
		$typeid = $type;
	} else {
		if(in_array($type,array('torrent'))) {
			$typeid = 13;
		} elseif(in_array($type,array('pdf'))) {
			$typeid = 12;
		} elseif(in_array($type,array('jpg','gif','png','bmp'))) {
			$typeid = 11;
		} elseif(in_array($type,array('swf','fla','flv','swi'))) {
			$typeid = 10;
		} elseif(in_array($type,array('wav','mid','mp3','m3u','wma','asf','asx','vqf','mpg','mpeg','avi','wmv'))) {
			$typeid = 9;
		} elseif(in_array($type,array('ra','rm','rv'))) {
			$typeid = 8;
		} elseif(in_array($type,array('php','js','pl','cgi','asp'))) {
			$typeid = 7;
		} elseif(in_array($type,array('txt','rtf','wri','chm'))) {
			$typeid = 6;
		} elseif(in_array($type,array('ppt','doc'))) {
			$typeid = 5;
		} elseif(in_array($type,array('rar'))) {
			$typeid = 4;
		} elseif(in_array($type,array('zip','arj','arc','cab','lzh','lha','tar','gz'))) {
			$typeid = 3;
		} elseif(in_array($type,array('exe','com','bat','dll'))) {
			$typeid = 2;
		} elseif($type) {
			$typeid = 1;
		} else {
			$typeid = 0;
		}
	}
	if($returnval == 'html') {
		return '<img src="images/filetype/'.$attachicons[$typeid].'" border="0" class="vm" alt="" />';
	} elseif($returnval == 'id') {
		return $typeid;
	}
}############################
?>